<template>
  <el-dialog v-model="alterShow" title="订单延期情况">
    <el-table :data="gridData" :cell-style="cellStyle">
      <el-table-column property="name" label="客户姓名" width="120" />
      <el-table-column property="status" label="订单状态" width="150" />
      <el-table-column property="executor" label="负责人" width="120" />
      <el-table-column property="num" label="联系电话" />
      <el-table-column property="Delayed" label="延期情况" />
    </el-table>
  </el-dialog>
</template>

<script lang="ts" setup>
import {ref} from 'vue';
import { tbGetUserInfo } from '/@/api/tb/tbOrder';
import { getAletrOrderTip } from '/@/api/tb/tbOrderStatus';
const alterShow = ref<boolean>(false);
const gridData = ref([])
const cellStyle=({row, column, rowIndex, columnIndex}) => {
   if(row.Delayed=="将要延期" && columnIndex===4){
    return{color:"#CC9900"}
   }
   else if(row.Delayed=="已经延期" && columnIndex===4){
    return{color:"red"}
   }
   else if(row.Delayed=="待确认工地情况" && columnIndex===4){
    return{color:"green"}
   }
}
const alter = async () => {
  const res=await tbGetUserInfo()
  for(let i=0;i<res?.data.post?.length;i++){
    if(res?.data.post[i].postName=="订单管理员" && sessionStorage.getItem("isFirst")=='true')
      {   
       const AlterOrderTip = await getAletrOrderTip();
       console.log(AlterOrderTip.data)
       if(AlterOrderTip.result){
          gridData.value = AlterOrderTip.data;
          alterShow.value = true;
          sessionStorage.setItem("isFirst", false)
       }
      }
    }
};
alter()
</script>

<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
